/* OpenStereo Library - A library to support the development of real time stereoscopic applications.
 * Copyright (C) 2007  Pedro Leite.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef sl_h
#define sl_h

#ifdef __cplusplus
	extern "C" {
#endif

#define SL_VERSION_1_0		1

#ifndef SL_API
	#ifdef WIN32
		#ifdef SLDLL_EXPORTS
			#define SL_API __declspec(dllexport)
			#define SL_API_ENTRY __stdcall
		#else
			#define SL_API __declspec(dllimport)
			#define SL_API_ENTRY __stdcall
		#endif
	#else
		#define SL_API
		#define SL_API_ENTRY
	#endif
#endif

/* Datatypes */

typedef unsigned int SLuint;
typedef int SLint;
typedef int SLbool;
typedef void* SLData;

typedef void (*SLScene) (void);

struct _SLStereoData {
	SLData left;
	SLData right;
	SLData stereo;
};

struct _SLVector3 {
	float x;
	float y;
	float z;
};

struct _SLCamera {
	float aperture;
	float focalLength;
	float eyeSeparation;
	struct _SLVector3 viewPosition;
	struct _SLVector3 viewDirection;
	struct _SLVector3 viewUp;
};

//typedef struct _SLContext* SLContext;
typedef struct _SLPlugin* SLPlugin;
typedef struct _SLViewport* SLViewport;
typedef struct _SLCamera* SLCamera;
typedef struct _SLStereoData* SLStereoData;

#define SL_TRUE		1
#define SL_FALSE	0

/* Enums */

typedef enum {
	SL_TRUE_COLOR_ANAGLYPH,
	SL_GRAY_ANAGLYPH,
	SL_HALF_COLOR_ANAGLYPH,
	SL_COLOR_ANAGLYPH,
	SL_OPTIMIZED_ANAGLYPH
} SLAnaglyphMethod;

/* Errors */

// TODO Erros de plugins

#define SL_NO_ERROR								0
#define SL_INVALID_PARAMETER					1
#define SL_CANNOT_CREATE_CONTEXT				1
#define SL_CONTEXT_ALREADY_CREATED				1
#define SL_CONTEXT_NOT_INITIALIZED				1
#define SL_CONTEXT_ALREADY_INITIALIZED			1

#define SL_INVALID_PLUGIN						1
#define SL_INVALID_PLUGIN_FILE					1
#define SL_INVALID_PLUGIN_FILE_FORMAT			1
#define SL_CANNOT_OPEN_PLUGIN					1
#define SL_PLUGIN_ALREADY_LOADED				1

#define SL_CANNOT_CREATE_VIEWPORT				1
#define SL_CANNOT_DESTROY_STEREO_PAIRS			1
#define SL_INVALID_VIEWPORT						1
#define SL_VIEWPORT_ALREADY_ADDED				1

#define SL_CANNOT_CREATE_CAMERA					1

/* Context functions */

SL_API void SL_API_ENTRY slCreateContext(void);
SL_API void SL_API_ENTRY slDestroyContext(void);

/* Error functions */

SL_API int SL_API_ENTRY slGetError(void);

/* Plugin functions */

SL_API void SL_API_ENTRY slLoadPlugin(const char* filePath, SLuint* pluginID);
SL_API void SL_API_ENTRY slBindPlugin(SLuint pluginID);
SL_API void SL_API_ENTRY slUnloadPlugin(SLuint pluginID);

/* Viewport functions */

SL_API SLViewport SL_API_ENTRY slCreateViewport(SLuint width, SLuint height);
SL_API void SL_API_ENTRY slDestroyViewport(SLViewport viewport);

SL_API void SL_API_ENTRY slSetDimension(SLViewport viewport, SLuint width, SLuint height);
SL_API SLuint SL_API_ENTRY slGetWidth(SLViewport viewport);
SL_API SLuint SL_API_ENTRY slGetHeight(SLViewport viewport);

SL_API void SL_API_ENTRY slSetAnaglyphMethod(SLViewport viewport, SLAnaglyphMethod method);
SL_API SLAnaglyphMethod SL_API_ENTRY slGetAnaglyphMethod(SLViewport viewport);

SL_API void SL_API_ENTRY slSetCamera(SLViewport viewport, SLCamera camera);
SL_API SLCamera SL_API_ENTRY slGetCamera(SLViewport viewport);

SL_API void SL_API_ENTRY slSetScene(SLViewport viewport, SLScene scene);

SL_API void SL_API_ENTRY slBindViewport(SLViewport viewport);

SL_API void SL_API_ENTRY slRenderScene(void);

/* Camera functions */

SL_API SLCamera SL_API_ENTRY slCreateCamera(void);
SL_API void SL_API_ENTRY slDestroyCamera(SLCamera camera);

/* SL State Machine functions */

// TODO define the state machine access
// SL_VIEWPORT_CAMERA, SL_VIEWPORT_DIMENSION, SL_VIEWPORT_WIDTH, SL_VIEWPORT_HEIGHT
// SL_VIEWPORT_ANAGLYPH_METHOD,

// SL_API void SL_API_ENTRY slGet(SLuint constant);

#ifdef __cplusplus
	}
#endif

#endif
